<template>
  <div>
    <BizDashboardTable
      v-if="currentCard === tableCard"
      :group="currentGroup"
      @show-edit-table="showEditTable"
    ></BizDashboardTable>
    <BizDashboardEditTable
      v-if="currentCard === editTableCard"
      :recode="currentRecode"
      :group="currentGroup"
      :group-options="currentGroupOptions"
      @show-table="showTable"
    ></BizDashboardEditTable>
  </div>
</template>

<script setup lang="ts">
import BizDashboardTable from '@/views/bizDashboard/BizDashboardTable.vue';
import type { Chart } from '@/api/bizDashboard/bizDashboard';
import BizDashboardEditTable from '@/views/bizDashboard/BizDashboardEditTable.vue';
import type { SelectProps } from 'ant-design-vue';

//列表页面
const tableCard = 'tableCard';
//编辑页面
const editTableCard = 'editTableCard';

//当前页面
let currentCard = ref(tableCard);

//编辑记录
let currentRecode = ref<Chart>();
//分组
let currentGroup = ref(0);
//分组
let currentGroupOptions = ref<SelectProps['options']>();

function showEditTable(editRecode: Chart, group: number, groupOptions: SelectProps['options']) {
  currentCard.value = editTableCard;
  currentRecode.value = editRecode;
  currentGroup.value = group;
  currentGroupOptions.value = groupOptions;
}

function showTable(group: number) {
  currentGroup.value = group;
  currentCard.value = tableCard;
}
</script>

<style lang="less" scoped></style>
